<template>
  <div id="upload">
    <div class="upload_left">
      <Menu theme="light" active-name="1" @on-select="select">
        <Menu-group title="视频管理">
          <Menu-item name="my-video">
            <Icon type="document-text"></Icon>
            我的视频
          </Menu-item>
          <Menu-item name="up-video">
            <Icon type="chatbubbles"></Icon>
            发布视频
          </Menu-item>
        </Menu-group>
        <Menu-group title="贴文管理">
          <Menu-item name="my-post">
            <Icon type="heart"></Icon>
            我的贴文
          </Menu-item>
          <Menu-item name="up-post">
            <Icon type="heart-broken"></Icon>
            发布贴文
          </Menu-item>
        </Menu-group>
      </Menu>
    </div>
    <div class="upload_right">
      <router-view :userInfo = "userInfo" />
    </div>
  </div>
</template>

<script>
import { getPersonInfo } from "@/utils/api";
export default {
  name: "Upload",
  data() {
    return {
      userInfo:{},//用户信息
      toWhere: "", //默认子路由地址
    };
  },
  methods: {
    select(name) {
      this.$router.push({
        path: "/bingo/User_home/upload/" + name,
      });
    },
  },
  created() {
    getPersonInfo().then((res) => {
      this.userInfo = res.data.resultMap;
    });
  },
  beforeRouteEnter(to, from, next) {

    next((vm) => {
      // 通过 `vm` 访问组件实例
      // 将访问此页面的下一个路由地址保存在this.toWhere
      vm.toWhere = to.fullPath;
      if (to.fullPath == "/bingo/User_home/upload") {
        vm.$router.push({ path: "/bingo/User_home/upload/my-video" });
      } else {
        vm.$router.push({ path: to.fullPath });
      }
    });
  },
};
</script>

<style scoped>
#upload {
  display: flex;
  flex-direction: row;
}
</style>
